﻿using System;

namespace VSTalk.Engine.Core.Feed
{
    public class DirectMessageProvider : IMessageProvider
    {
        public void EmitMessage(IMessage message)
        {
            if (message.ClientId == default(Guid))
                throw new ArgumentException("ClientId is required", "message");
            OnMessageReceived(new MessageReceivedArgs
            {
                Message = message
            });
        }

        public event EventHandler<MessageReceivedArgs> MessageReceived;

        protected virtual void OnMessageReceived(MessageReceivedArgs e)
        {
            var handler = MessageReceived;
            if (handler != null) handler(this, e);
        }
    }
}